package com.fat.utils;


import com.fat.entity.User;

public class UserHolder {
    private static ThreadLocal<User> userThreadLocal = new ThreadLocal<>();

    // 保存当前用户信息到 ThreadLocal
    public static void saveUser(User user) {
        userThreadLocal.set(user);
    }

    // 获取当前用户信息
    public static User getUser() {
        return userThreadLocal.get();
    }

    // 清除当前线程中的用户信息
    public static void clear() {
        userThreadLocal.remove();
    }
}

